#pragma once
#include <linux/videodev2.h>
#include "h264encoder.h"
#include <stddef.h>
#include <stdint.h>

struct buff {
    void *start;
    size_t length;
};

typedef struct v4lCamera
{
    char *device_name;
    int fd;
    int width;
    int height;
    int display_depth;
    uint8_t *h264_buf;
    uint8_t encodeedLength;

    int buff_num;
    struct buffer *buffers;
    struct v4l2_capability v4l2_cap;
} IOTC_Camera;

void camera_init(IOTC_Camera *cam);
int camera_open(IOTC_Camera *cam);
int camera_capturing_start(IOTC_Camera *cam);
void camera_capturing_stop(IOTC_Camera *cam);
int read_and_encode_frame(IOTC_Camera *cam);
void camera_unint(IOTC_Camera *cam);
int camera_close(IOTC_Camera *cam);

